ConstantOfShape
将给定内存区间内的所有元素填充为指定的常量值。对于复数类型,实部和虚部需分别传入。
- 输入:
output - 输出数据的起始地址。
start - 填充的起始索引(包含)。
end - 填充的结束索引(不包含)。
value - 需要填充的常量值(针对非复数类型)。
value_real - 复数常量的实部(针对复数类型)。
value_imag - 复数常量的虚部(针对复数类型)。
core_mask - 核掩码(仅适用于共享存储版本)。
- 输出:
output - 填充完成后的数据地址。
- 支持平台:
FT78NEMT7004备注
FT78NE 支持 int8, int16, int32, fp32, fp64, cplx64, cplx128
MT7004 支持 fp16, fp32, int16, int32, cplx64
共享存储版本:
-
void i8_constant_of_shape_s(int8_t *output, int start, int end, int8_t value, int core_mask)
-
void i16_constant_of_shape_s(int16_t *output, int start, int end, int16_t value, int core_mask)
-
void i32_constant_of_shape_s(int32_t *output, int start, int end, int32_t value, int core_mask)
-
void fp_constant_of_shape_s(float *output, int start, int end, float value, int core_mask)
-
void dp_constant_of_shape_s(double *output, int start, int end, double value, int core_mask)
-
void c64_constant_of_shape_s(float *output, int start, int end, float value_real, float value_imag, int core_mask)
-
void c128_constant_of_shape_s(double *output, int start, int end, double value_real, double value_imag, int core_mask)
C调用示例(Float32):
1#include <stdio.h> 2 3int main(int argc, char* argv[]) { 4 // output在DDR空间 5 float *output = (float *)0xA0000000; 6 int start = 0; 7 int end = 16000; 8 float value = 1.5f; 9 int core_mask = 0xff; 10 11 // 多核并行填充 12 fp_constant_of_shape_s(output, start, end, value, core_mask); 13 14 return 0; 15}
C调用示例(Complex64):
1#include <stdio.h> 2 3int main(int argc, char* argv[]) { 4 // output在DDR空间,c64类型通常使用float*指针访问 5 float *output = (float *)0xA0000000; 6 int start = 0; 7 int end = 1000; // 1000个复数元素 8 float val_r = 0.5f; 9 float val_i = -0.5f; 10 int core_mask = 0xff; 11 12 // 注意:c64接口需分别传入实部和虚部 13 c64_constant_of_shape_s(output, start, end, val_r, val_i, core_mask); 14 15 return 0; 16}
私有存储版本:
-
void i8_constant_of_shape_p(int8_t *output, int start, int end, int8_t value)
-
void i16_constant_of_shape_p(int16_t *output, int start, int end, int16_t value)
-
void i32_constant_of_shape_p(int32_t *output, int start, int end, int32_t value)
-
void fp_constant_of_shape_p(float *output, int start, int end, float value)
-
void dp_constant_of_shape_p(double *output, int start, int end, double value)
-
void c64_constant_of_shape_p(float *output, int start, int end, float value_real, float value_imag)
-
void c128_constant_of_shape_p(double *output, int start, int end, double value_real, double value_imag)
C调用示例:
1#include <stdio.h> 2 3int main(int argc, char* argv[]) { 4 // output在L2空间 5 float *output = (float *)0x10810000; 6 int start = 0; 7 int end = 1024; 8 float value = 3.14f; 9 10 fp_constant_of_shape_p(output, start, end, value); 11 12 return 0; 13}